package com.crishne.anwo.utill;

import java.io.OutputStream;
import java.net.URLEncoder;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.View;

@Component("common_image_view")
public class CommonImageView implements View {

	public String getContentType() {
		return "image/jpeg";
	}

	@SuppressWarnings("rawtypes")
	public void render(Map map, HttpServletRequest request, HttpServletResponse response) throws Exception {
		response.setContentType(this.getContentType());
		String stFilename = (String)map.get("stFilename");
		byte[] byContent = (byte[])map.get("byContent");
		response.setHeader("Content-disposition", "attachment; filename=\"" + stFilename + "\"");
		OutputStream os = response.getOutputStream();
		os.write(byContent);
		os.flush();
		os.close();
	}
}
